package com.chia.multienty.core.controller;


import com.chia.multienty.core.domain.condition.UserCondition;
import com.chia.multienty.core.domain.condition.WorkflowCondition;
import org.springframework.context.annotation.Conditional;
import org.springframework.web.bind.annotation.RequestMapping;
import com.chia.multienty.core.service.ProcessBindService;
import com.chia.multienty.core.domain.dto.ProcessBindDTO;
import com.chia.multienty.core.pojo.ProcessBind;
import com.chia.multienty.core.parameter.user.ProcessBindDetailGetParameter;
import com.chia.multienty.core.parameter.user.ProcessBindPageGetParameter;
import com.chia.multienty.core.parameter.user.ProcessBindDeleteParameter;
import com.chia.multienty.core.parameter.user.ProcessBindSaveParameter;
import com.chia.multienty.core.parameter.user.ProcessBindUpdateParameter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.chia.multienty.core.annotation.WebLog;
import com.chia.multienty.core.domain.basic.Result;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
 * <p>
 * 工作流程绑定数据 服务
 * </p>
 *
 * @author Multi Tenant Auto Generator
 * @since 2024-07-20
 */
@RestController
@Validated
@RequestMapping("/process-bind")
@RequiredArgsConstructor
@Api(tags = "工作流程绑定数据")
@Conditional(UserCondition.class)
public class ProcessBindController {
    private final ProcessBindService processBindService;
    @PostMapping("/detail")
    @ApiOperation("获取工作流程绑定数据详情")
    public Result<ProcessBindDTO> getDetail(@Validated @RequestBody ProcessBindDetailGetParameter parameter) {
        ProcessBindDTO detail = processBindService.getDetail(parameter);
        return new Result<>(detail);
    }

    @PostMapping("/page")
    @ApiOperation("获取工作流程绑定数据分页列表")
    public Result<IPage<ProcessBindDTO>> getPage(@Validated @RequestBody ProcessBindPageGetParameter parameter) {
        IPage<ProcessBindDTO> page = processBindService.getPage(parameter);
        return new Result<>(page);
    }

    @PostMapping("/update")
    @ApiOperation("更新工作流程绑定数据")
    @WebLog(target = "ProcessBind")
    public Result<Boolean> update(@Validated @RequestBody ProcessBindUpdateParameter parameter) {
        processBindService.update(parameter);
        return new Result<>(true);
    }

    @PostMapping("/save")
    @ApiOperation("保存工作流程绑定数据")
    @WebLog(target = "ProcessBind")
    public Result<Boolean> save(@Validated @RequestBody ProcessBindSaveParameter parameter) {
        processBindService.save(parameter);
        return new Result<>(true);
    }


    @DeleteMapping("/delete")
    @ApiOperation("删除工作流程绑定数据")
    @WebLog(target = "ProcessBind")
    public Result<Boolean> delete(@Validated @RequestBody ProcessBindDeleteParameter parameter) {
        processBindService.delete(parameter);
        return new Result<>(true);
    }

}
